*** Settings ***
Documentation    TC06-Update Lane LCL
Resource    ../../Keywords/Common_Head.robot
Force Tags    P3
Metadata    Author    Momo
Metadata    ID    6855206


*** Test Cases ***
TC06-Update Lane LCL
    Step 1 User Goes To Basic Data Management Tender List
    Step 2 User Goes To Pricing Collaboration Pricing Project
    Step 3 Input Following Attributes
    Step 4 User Selects Row That Project Name Is 20240815 LCL
    Step 5 Click On Copy Data
    Step 6 Input Tender ID With Value 2024000001 Click On Search
    Step 7 Select This Entry Click On Copy Data Button And Yes In
    Step 8 Select Current Project In Pricing Project Click On
    Step 9 Click Skip Button In Step4 and Yes In The Pop up
    Step 10 User Clicks Next Round Management Button
    Step 11 User Clicks Update Lane Button
    Step 12 Select Update Existing Lanes
    Step 13 User Clicks Download Button
    Step 14 User Opens The Downloaded File
    Step 15 User Modifies Some Customized Data From The Download
    Step 16 User Modifies Some Pricing Data From The Download File
    Step 17 User Modifies Some Pricing Data From The Download File 2
    Step 18 Click On Download Button Check The Downloaded File
    Step 19 In Pricing Project Page User Selects TenderID Contains
    Step 20 Select This Project 20240815 FCL Regression Click On
    Step 21 User Goes To Basic Data Management Tender List 2



*** Keywords ***
Step ${step} User Goes To Basic Data Management Tender List
    #************************Step 1******************************
    #  Do:
    #      User goes to Basic Data Management Tender List
    #      Click Create button
    #      Input with following attributes
    #      Tender ID some numbers such as 202408151435001 you can
    #     input with current datetime and some random number to
    #     avoid duplicate validation
    #      Tender Title some value such as Regression Test by
    #     Wendy001
    #      Customer 815 Miele
    #      Mode select all
    #      Level Global
    #      Click on Save button
    #  Expected:
    #      Created successfully with the message Tender has been
    #     added
    #************************************************************
    ${G_TENDERID}    Generate Tender ID
    ${TenderTitle}   Set Variable    Regression Test by auto
    Set Suite Variable     ${G_TENDERID}
    Login Space
    Create Tender    ${G_TENDERID}    ${TenderTitle}    815    true    true    true
    ${PROJECT}    Copy Dictionary    ${PROJECT_PARAM}
    Set To Dictionary    ${PROJECT}
    ...    TENDER_ID=${G_TENDERID}    TENDER_TITLE=${TenderTitle}    CUSTOEMR_NAME=Miele    CUSTOMER_LEVEL=Global
    ...   MODE=LCL    DEPUTY=SNOWLI01    TEMPLATE=${CURDIR}${/}TestData${/}LCLTemplate-Location-all.xlsx
    Set Suite Variable     ${PROJECT}

Step ${step} User Goes To Pricing Collaboration Pricing Project
    #************************Step 2******************************
    #  Do:
    #      User goes to Pricing Collaboration Pricing Project
    #      User clicks Create Project button
    #  Expected:
    #      A New Project dialog should be opened successfully
    #************************************************************
    Create Project    ${PROJECT}

Step ${step} Input Following Attributes
    #************************Step 3******************************
    #  Do:
    #      Input following attributes
    #      Tender ID 20240815 Regression
    #      Mode LCL
    #      Deadline to TM current date 10 day
    #      Rate Validity From current date
    #      Rate Validity To current date 100 day
    #      Deputies NATZHANG
    #      Description for regression
    #      Click on Save button
    #  Expected:
    #      A new project is created successfully
    #************************************************************
    Log    Done in step 3

Step ${step} User Selects Row That Project Name Is 20240815 LCL
    #************************Step 4******************************
    #  Do:
    #      User selects row that project name is 20240815 LCL
    #     Regression
    #  Expected:
    #      The row can be selected successfully
    #************************************************************
    Search Project    ${PROJECT.TENDER_ID}

Step ${step} Click On Copy Data
    #************************Step 5******************************
    #  Do:
    #      Click on Copy Data
    #  Expected:
    #      A dialogue named Copy Target to Project 20240815 LCL
    #     Regression display
    #      Search Criteria
    #      Mode with value LCL uneditable
    #      Customer name with no value
    #      Tender ID with value ALL Editable
    #      Tender Lead with value ALL Editable
    #      RFQ Launch Date with value DD MM YYYY Editable
    #      Search button
    #      Result list has no entry present
    #      Copy Data button is disable now
    #************************************************************
    Copy Data    2024000001    LCL    do not touch me

Step ${step} Input Tender ID With Value 2024000001 Click On Search
    #************************Step 6******************************
    #  Do:
    #      Input Tender ID with value 2024000001 click on Search
    #     button
    #  Expected:
    #      index php attachments get bbed6818 f35c 4750 983e
    #     8bad0a53a928 Result list has one entry as above
    #     information
    #************************************************************
    Log    Done in step 5

Step ${step} Select This Entry Click On Copy Data Button And Yes In
    #************************Step 7******************************
    #  Do:
    #      Select this entry click on Copy Data button and Yes in
    #     pop up window
    #  Expected:
    #      Successfully with messages in pop up window
    #      Tender has been successfully copied from 2024000001 LCL
    #     do not touch me
    #      Please adjust the template and the lanes in Template
    #     Lane Management page if required
    #      After click on OK button
    #      The same message is displayed in Pricing Project page
    #     too
    #************************************************************
    Log    Done in step 5

Step ${step} Select Current Project In Pricing Project Click On
    #************************Step 8******************************
    #  Do:
    #      Select current project in pricing project click on
    #     template management button
    #  Expected:
    #      In the dialog check the information under Step2 should
    #     be the same as project 2024000001 LCL do not touch me
    #************************************************************
    Search Project    ${PROJECT.TENDER_ID}  
    Wait Until Search Finished
    Wait Until Keyword Succeeds    5x    300ms    Click    ${Project_toolbar_TemplateManagementButton}

Step ${step} Click Skip Button In Step4 and Yes In The Pop up
    #************************Step 9******************************
    #  Do:
    #      Click Skip button in Step4 and Yes in the pop up
    #     windown
    #  Expected:
    #      Next Round Management button is enable
    #************************************************************
    Push Skip and check for AIR Template
    Wait Until Search Finished

Step ${step} User Clicks Next Round Management Button
    #************************Step 10******************************
    #  Do:
    #      User clicks Next round management button
    #  Expected:
    #      A dialogue named Project 20240815 FCL Regression Round1
    #     display
    #      It divides into 5 parts
    #      1 Generation Information current Pricing Round 1
    #     Started 2 lanes
    #      2 Assignment
    #      3 Attached Document
    #      4 Round History
    #      5 The tasks status Region Country My tasks
    #************************************************************
    Click    //button[contains(text(),"Next: Round Management")]
    Wait For Elements State    //h4/span[contains(text(),"Project ${G_TENDERID}-LCL-${PROJECT.TENDER_TITLE}")]
    Wait For Elements State    //legend[.="Generation Information"]
    Wait For Elements State    //legend[.="Assignment"]
    Wait For Elements State    //legend[.="Attached Document"]
    Wait For Elements State    //legend[.="Round History"]
    Wait For Elements State    //a[.="Region"]
    Wait For Elements State    //a[.="My Tasks"]

Step ${step} User Clicks Update Lane Button
    #************************Step 11******************************
    #  Do:
    #      User clicks update lane button
    #  Expected:
    #     1. A dialog with the name of project name is displayed".
    #     2. There are three check boxes: update existing lanes, delete existing lanes and add new lanes.
    #     3. There are two boxes:next and close.
    #************************************************************
    Click    ${Project_RoundMgmt_UpdateLaneButton}
    Wait For Elements State    //legend[.="I want to:"]/following-sibling::div//input[@value="update"]
    Get Text    //legend[.="I want to:"]/following-sibling::div//input[@value="update"]/..    contains    Update Existing Lanes
    Wait For Elements State    //legend[.="I want to:"]/following-sibling::div//input[@value="delete"]
    Get Text    //legend[.="I want to:"]/following-sibling::div//input[@value="delete"]/..    contains    Delete Existing Lanes
    Wait For Elements State    //legend[.="I want to:"]/following-sibling::div//input[@value="create"]
    Get Text    //legend[.="I want to:"]/following-sibling::div//input[@value="create"]/..    contains    Add New Lanes
    Wait For Elements State    //button[.="Next"]
    Wait For Elements State    //button[.="Next"]/following-sibling::button

Step ${step} Select Update Existing Lanes
    #************************Step 12******************************
    #  Do:
    #      Select Update Existing Lanes, click on Next button.
    #  Expected:
    #     1. A new dialog with the name of project name is displayed.
    #     2. Download, Upload, Back, Close buttons are displayed.
    #************************************************************
    Click    //button[.="Next"]
    Wait For Elements State    ${Project_UpdateLane_DownloadButton}
    Wait For Elements State    ${Project_UpdateLane_UploadButton}
    Wait For Elements State    ${Project_UpdateLane_CloseButton}
    Wait For Elements State    //button[.="Back"]

Step ${step} User Clicks Download Button
    #************************Step 12******************************
    #  Do:
    #      User clicks download button
    #  Expected:
    #      A file downloads successfully
    #************************************************************
    ${filename}    Download File    ${Project_UpdateLane_DownloadButton}
    Set Test Variable    ${filename}    ${filename}
    Wait Until Search Finished

Step ${step} User Opens The Downloaded File
    #************************Step 13******************************
    #  Do:
    #      User opens the downloaded file
    #  Expected:
    #      The download file has all of the pricing information It
    #     has two lanes
    #************************************************************
    Open Excel Document     ${filename}    ${PROJECT.MODE}
    ${landInfo}    Read Excel Column    1
    ${rowCount}    Get Length    ${landInfo}
    Should Be Equal As Integers    ${rowCount}    6

Step ${step} User Modifies Some Customized Data From The Download
    #************************Step 14******************************
    #  Do:
    #      User modifies some customized data from the download
    #     file and upload this file as index php attachments get
    #     35619934 06ad 4568 b6ab c8f7cbd68289
    #  Expected:
    #      A prompt Upload Result appears on the top
    #      Upload Result
    #      Upload Failed
    #      Error in excel row 5
    #      Input value exceeds the constraint max length of this
    #     is 256 characters Please check and revise AQ
    #      123123123123 123 must be in decimal format Please check
    #     and revise AR
    #      Unknown currency code Please check and revise AS
    #************************************************************
    Write Excel Cell    5    43    abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc    ${PROJECT.MODE}_D
    Write Excel Cell    5    44    123123123123.123    ${PROJECT.MODE}_D
    Write Excel Cell    5    45    aaa    ${PROJECT.MODE}_D
    Save Excel Document    ${filename}
    Close Current Excel Document
    Reopen And Save Excel    ${filename}
    Wait Until Keyword Succeeds   100    1    Click    ${Project_UpdateLane_UploadButton}
    Wait For Elements State   ${upload_addFileButton}     enabled
    Sleep    2
    Upload File By Selector    ${upload_addFileButton}    ${filename}
    Wait Until Search Finished
    Wait For Elements State    //h4[.="Error in excel row 5"]    timeout=30s
    Wait For Elements State    //li[.="Input value exceeds the constraint, max length of this is 256 characters. Please check and revise! [ AQ ]"]
    Wait For Elements State    //li[.="123123123123.123 must be in decimal format. Please check and revise! [ AR ]"]
    Wait For Elements State    //li[.="Unknown currency code. Please check and revise! [ AS ]"]
    Click    //button[span[.="OK"]]

Step ${step} User Modifies Some Pricing Data From The Download File
    #************************Step 15******************************
    #  Do:
    #      User modifies some pricing data from the download file
    #     and upload this file as index php attachments get
    #     f245d51d 5cc0 4e58 8485 c20ed95401f9
    #  Expected:
    #      A prompt Upload Result appears on the top
    #      Upload Failed
    #      Error in excel row 5
    #      abc must be in decimal format Please check and revise
    #     BW
    #      abc2 must be in decimal format Please check and revise
    #     BY
    #************************************************************
    Open Excel Document     ${filename}    ${PROJECT.MODE}
    Write Excel Cell    5    43    ${EMPTY}    ${PROJECT.MODE}_D
    Write Excel Cell    5    44    ${EMPTY}    ${PROJECT.MODE}_D
    Write Excel Cell    5    45    ${EMPTY}    ${PROJECT.MODE}_D
    Write Excel Cell    5    75    abc    ${PROJECT.MODE}_D
    Write Excel Cell    5    77    abc2    ${PROJECT.MODE}_D
    Save Excel Document    ${filename}
    Close Current Excel Document
    Reopen And Save Excel    ${filename}
    Wait Until Keyword Succeeds   100    1    Click    ${Project_UpdateLane_UploadButton}
    Wait For Elements State   ${upload_addFileButton}     enabled
    Sleep    2
    Upload File By Selector    ${upload_addFileButton}    ${filename}
    Wait Until Search Finished
    Wait For Elements State    //h4[.="Error in excel row 5"]
    Wait For Elements State    //li[.="abc must be in decimal format. Please check and revise! [ BW ]"]
    Wait For Elements State    //li[.="abc2 must be in decimal format. Please check and revise! [ BY ]"]
    Click    //button[span[.="OK"]]

Step ${step} User Modifies Some Pricing Data From The Download File 2
    #************************Step 16******************************
    #  Do:
    #      User modifies some pricing data from the download file
    #     according to the error message
    #  Expected:
    #      Successfully uploaded
    #************************************************************
    Open Excel Document     ${filename}    ${PROJECT.MODE}
    Write Excel Cell    5    75    11    ${PROJECT.MODE}_D
    Write Excel Cell    5    77    22    ${PROJECT.MODE}_D
    Save Excel Document    ${filename}
    Close Current Excel Document
    Reopen And Save Excel    ${filename}
    Wait Until Keyword Succeeds   100    1    Click    ${Project_UpdateLane_UploadButton}
    Wait For Elements State   ${upload_addFileButton}     enabled
    Sleep    2
    Upload File By Selector    ${upload_addFileButton}    ${filename}
    Wait Until Search Finished
    Wait For Elements State    //span[.="Successfully uploaded"]

Step ${step} Click On Download Button Check The Downloaded File
    #************************Step 17******************************
    #  Do:
    #      Click on Download button check the downloaded file
    #  Expected:
    #      File download successfully and check the modified place
    #     are the same with the download file
    #************************************************************
    ${filename}    Download File    ${Project_UpdateLane_DownloadButton}
    Set Test Variable    ${filename}    ${filename}
    Wait Until Search Finished
    Open Excel Document     ${filename}    ${PROJECT.MODE}
    Check Cell Value    5    75    11.0    ${PROJECT.MODE}_D
    Check Cell Value    5    77    22.0    ${PROJECT.MODE}_D
    Close Current Excel Document

Step ${step} In Pricing Project Page User Selects TenderID Contains
    #************************Step 18******************************
    #  Do:
    #      In Pricing Project page User selects TenderID Contains
    #     20240815
    #  Expected:
    #      The project with LCL mode could be found
    #************************************************************
    Click   ${Project_UpdateLane_CloseButton}
    Wait Until Search Finished
    Click    css=[data-ng-click="closeRoundPage()"]
    Wait For Elements State    //td[contains(text(),"${G_TENDERID}")]

Step ${step} Select This Project 20240815 FCL Regression Click On
    #************************Step 19******************************
    #  Do:
    #      Select this project 20240815 FCL Regression click on
    #     Delete Project button
    #      Click Yes of the pop up confirm window
    #  Expected:
    #      System displays Project has been deleted
    #************************************************************
    Delete Project    ${G_TENDERID}

Step ${step} User Goes To Basic Data Management Tender List 2
    #************************Step 20******************************
    #  Do:
    #      User goes to Basic Data Management Tender List
    #      Search out the tender created in step1
    #      Click on Delete button
    #      Click on Yes button in the popup dialog
    #  Expected:
    #      System displays Tender has been deleted
    #************************************************************
    Delete Tender    ${G_TENDERID}
